Skip to content

fix: ClassFormatError when serializing classes with array-typed field…#4014

Open
wenshao wants to merge 1 commit intomainfrom
fix/issue-4009-classformaterror
Open

fix: ClassFormatError when serializing classes with array-typed field…#4014
wenshao wants to merge 1 commit intomainfrom
fix/issue-4009-classformaterror

Conversation

@wenshao
Copy link
Member

@wenshao wenshao commented Mar 10, 2026

…s, for issue #4009

When calling JSON.toJSON() on objects with Class[] or other array-typed fields, the ASM-based JIT code generator was creating class names like 'OWG_5_0_Class[]' which contain illegal characters for Java class names.

Added sanitizeClassName() helper method to ObjectWriterCreatorASM and ObjectReaderCreatorASM to sanitize class simple names by converting array notation (e.g., 'Class[]' -> 'ClassArray') and replacing other invalid characters with underscores.

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

…s, for issue #4009

When calling JSON.toJSON() on objects with Class[] or other array-typed
fields, the ASM-based JIT code generator was creating class names like
'OWG_5_0_Class[]' which contain illegal characters for Java class names.

Added sanitizeClassName() helper method to ObjectWriterCreatorASM and
ObjectReaderCreatorASM to sanitize class simple names by converting
array notation (e.g., 'Class[]' -> 'ClassArray') and replacing other
invalid characters with underscores.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant